<template>
    <div>
      <router-view 
      :likebooklist="likebooklist"
      :likebooklistchoose="likebooklistchoose" 
      @get-mounttask="btnMountTask" 
      :mounttask="mounttask" 
      @get-recommentask="btnRecommenTask" 
      :recommentask="recommentask" 
      @get-book-recharge="btnBookRechargeTask" 
      :bookrecharge="bookrecharge" 
      :bookrechargetask="bookrechargetask" 
      @get-book-shelf-task="btnBookShelfTask" 
      :bookshelftask="bookshelftask" 
      @get-login-task="btnLoginTask" 
      :logintask="logintask" 
      @get-weektime="btnWeek" 
      :daynum="daynum" 
      :weektime="weektime" 
      @get-mount="mountSum" 
      @get-recommen="recommenSum" 
      @get-sum="btnSum" 
      @get-coin="getCoin" 
      @get-login="getLogin" 
      @get-bookshelf="btnBookShelf" 
      @get-book-id="btnBookId" 
      @send-comment="btnSendComment" 
      :commentlist="commentlist" 
      :bookids="bookid" 
      :bookshelf="bookshelf"
      :bookshelflist="bookshelflist" 
      :login="login" 
      :coin="coin" 
      :coupon="coupon" 
      :recommen="recommen" 
      :mount="mount"></router-view>
    </div>
</template>


<script>
import {getBookDetail} from "../src/api/bookdetail"
export default {
  data(){
    return {
      bookid:null,
      listid:null,
      commentlist:[],
      bookshelflist:[],
      bookshelf:null,
      login:false,
      coin:0,
      coupon:10,
      recommen:10,
      mount:10,
      likebooklist:[],
      weektime:null,//星期几数据
      daynum:0,//签到天数
      logintask:false,//领取登录奖励
      bookshelftask:false,//领取添加书籍奖励
      bookrecharge:false,//个人充值
      bookrechargetask:false,//领取充值奖励
      mounttask:false,//领取月票奖励
      recommentask:false,//领取推荐票奖励
      likebooklistchoose:false
    }
  },
  methods:{
    //获取月票奖励
    btnMountTask(){
      this.mounttask=true
      this.coin+=5
      
    },

    //获取投推荐票奖励
    btnRecommenTask(){
      this.recommentask=true
      this.coin+=5
    },

    //获取充值奖励
    btnBookRechargeTask(){
      this.bookrechargetask=true
      this.coin+=5
    },

    //获取添加书籍奖励
    btnBookShelfTask(){
      this.bookshelftask=true
      this.coin+=5
    },

    //获取登录奖励
    btnLoginTask(){
      this.logintask=true
      this.coin+=5
    },

    //每日签到
    btnWeek(num){
      this.weektime=num
      this.coin+=5
      this.daynum+=1
    },

    //投月票
    mountSum(){
      this.mount=0
    },
    recommenSum(){
      this.recommen=0
    },

    //看小说消费金额
    btnSum(num){
      this.coin=this.coin-num
    },

    //获取个人充值金额
    getCoin(num){
      this.bookrecharge=true
      this.coin=this.coin+num*100
    },

    //登录
    getLogin(val){
      this.login=val
    },
    btnSendComment(val){
      this.commentlist.push(val)
    },
    btnBookId(id){
      this.bookid=id
      // console.log('主页的id',id)
    },
    btnBookShelf(id){
      this.bookshelf=id
    }
  },
  watch:{
    bookshelf:function(){
      this.likebooklist.push(this.bookshelf)
      getBookDetail({
        id:this.bookshelf
      }).then(data=>{
        this.bookshelflist.push(data.feed.entry)
        this.likebooklistchoose=true
      })
    }
  }
}
</script>

<style lang="less">
@import "./assets/css/base.css";

</style>